home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!russells
- From: russells@netcom.com (Russell Salsbury)
- Subject: Re: How to detect if a number has fractions
- Message-ID: <russellsDpMopI.Ks@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4kb1p8$gph@gate.compart.fi>
- Date: Wed, 10 Apr 1996 04:05:41 GMT
- Sender: russells@netcom10.netcom.com
-
- joonas.kervinen@pcb.compart.fi (joonas kervinen) writes:
-
- >Here's a small detail (not quite Win spesific, sorry!) that's bugging
- >me: How do I detect in Borland C (BCC4.5 or 5.0) whether a double
- >value has fractions. And I mean quickly, not using time consuming
- >floating point functions.
- >Please answer via e-mail.
-
- Why not use floating point?
-
- #include <math.h>
- int has_frac(double d)
- {
- if (d - floor(d) != 0.0) return 1;
- return 0;
- }
-
- Who the !#$^% would want MSWINdows!? Ewww.. cooties.
- Ryan russells@netcom.com
-